var pack = null;
function share_build(){
    var self_url = location.href.split('#')[0];
    console.log('self_url:'+self_url);
    var self_url_encode = encodeURIComponent(self_url);
    var sign_api = 'https://www.lvwker.top/wechat/share/share.php?self_url='+self_url_encode;

    $.get(sign_api, function (sign_pack) {
        pack = sign_pack;
        var configObj = {
            debug: false,
            appId: pack.appId,
            timestamp: pack.timestamp,
            nonceStr: pack.nonceStr,
            signature: pack.signature,
            jsApiList: [
                'onMenuShareTimeline',
                'onMenuShareAppMessage',
                'checkJsApi',
                'startRecord',
                'stopRecord',
                'translateVoice',
                'playVoice',
                'uploadVoice',
                'downloadVoice'
            ]
        };
        console.log('configObj:'+JSON.stringify(configObj));
        wx.config(configObj);

        wx.error(function(res){
            console.log('微信分享权限注入失败！'+res.errMsg);
        });

        wx.ready(function(){
          sharePage();
        });
    }, "json");
}

function sharePage() {
    var sharepage_conf = {
        title:pack.gametitle,
        desc:pack.gamedesc,
        link:pack.gamelink,
        imgUrl:pack.gameIconUrl
    }
    console.log('sharepage_conf:'+JSON.stringify(sharepage_conf));
    wx.onMenuShareAppMessage(sharepage_conf);
    wx.onMenuShareTimeline(sharepage_conf);
}
















